console.log('hello world!')

// fetch proxy api example
const ul = document.createElement('ul')
document.body.append(ul)
ul.style.backgroundColor = 'rgba(255,255,255,.6)'
ul.style.color = '#333'

// 跨域请求 虽然Github支持CORS，但不是每个服务端都应该支持
// const url = 'https://api.github.com/users'
// fetch(url)

const url = '/api/users' // http://localhost:8080/api/users
fetch(url)
  .then(res => res.json())
  .then(data => {
    const list = []
    data.forEach(v => {
      const li = document.createElement('li')
      li.textContent = v.login
      list.push(li)
    })
    ul.append(...list)
  })

